
const api = require('./api')
const brower = require('./brower')
async function app(){
  //let msg =  await api.getCanUseIp();
  // if(msg.state==1){   
  //   var reg = /(\d)+分?/;
  //   let f = msg.info.time.match(reg)[0].replace("分",'');
  //   if(parseInt(f)>=10){
  //       await api.tunIP();
  //   }else{ 
  //     brower.tasks(msg.info.ip);
  //   }
  // }else{
  //   await api.tunIP();
  // }
 // console.log(msg)

 let ips =  await api.getCanUseIp();
 console.log(ips)
 for (const iterator of ips) {
    await api.tunIP(iterator);
    console.log(iterator)
    let msg =  await api.getCurState();
    await brower.tasks(msg.info.ip);
 }
 
}
app();
setInterval(function(){
  app();
},60*1000*10);